package com.gitee.security.validate;

import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
public class Captcha implements Serializable {

    private String code;

    private LocalDateTime expireTime;

    public Captcha(String code, int expireDuration) {
        this.code = code;
        this.expireTime = LocalDateTime.now().plusSeconds(expireDuration);
    }

    public boolean isExpired() {
        return this.expireTime.isBefore(LocalDateTime.now());
    }
}
